﻿using System;
using System.Collections;
using System.Collections.Generic;


namespace DailyFx.UI
{

	/// <summary>
	///		Denotes a node within a parent/child hierarchy.
	/// </summary>
	public interface IUIChild
	{
		/// <summary>
		///		Gets or Sets the Parent
		/// </summary>
		object Parent { get; set; }
	}

	/// <summary>
	///		Denotes a node within a parent/child hierarchy.
	/// </summary>
	public interface IUIChild<TParent> : IUIChild
	{
		/// <summary>
		///		Gets or Sets the Parent
		/// </summary>
		new TParent Parent { get; set; }
	}

		/// <summary>
	///   Interface used to define an object associated to a collection of children.
	/// </summary>
	public interface IUIParent
	{
		/// <summary>
		///   Gets the children.
		/// </summary>
		IEnumerable GetChildren ();
	}

	/// <summary>
	///		Interface used to define a specialized parent.
	/// </summary>
#if !SILVERLIGHT || SL5 || WP8
	public interface IUIParent<out T> : IUIParent
#else
    public interface IParent<T> : IParent       
#endif
	{
		/// <summary>
		///   Gets the children.
		/// </summary>
		/// <returns>
		///   The collection of children.
		/// </returns>
		new IEnumerable<T> GetChildren();
	}

	/// <summary>
	///		maintains selection of children .
	/// </summary>
	public interface IUISelector
	{
		/// <summary>
		/// The currently selected child item.
		/// </summary>
		object SelectedChild { get; set; }
	}


	/// <summary>
	///		which conducts other objects by managing an selected child and maintaining a strict lifecycle.
	/// </summary>
	public interface IUIConductor : IUIParent, INotifyPropertyChangedEx
	{
		/// <summary>
		///		Selects the specified child item.
		/// </summary>
		/// <param name="item">The item to activate.</param>
		void EnableChild ( object item );

		/// <summary>
		///		Unselects the specified child item.
		/// </summary>
		void DisableChild (object item, bool close );

		/// <summary>
		///		Occurs when an enabling request is processed.
		/// </summary>
		event EventHandler<UIEnabledNotifyEventArgs> ChildRequireEnabled ;
	}

	public interface IUIConductor<T> : IUIConductor, IUIParent<T>, INotifyPropertyChangedEx
		where T : class 
	{
		/// <summary>
		///		Selects the specified child item.
		/// </summary>
		void EnableChild ( T item);

		/// <summary>
		///		Unselects the specified child item.
		/// </summary>
		void DisableChild ( T item, bool close );
	}
}
